perm filename VALIO.PAL[AL,HE]1 blob sn#290078 filedate 1977-06-28 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00004 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.SBTTL Value input and outout routines.
C00003 00003	 FLREAD, SCALIN, VECTIN, TRNSIN
C00007 00004	 SCLOUT, VECOUT, TRNOUT
C00009 ENDMK
C⊗;
.SBTTL Value input and outout routines.

COMMENT ⊗ This file uses routines RELSCN, CVG from FLOAT.PAL, several
utilities (CURIN, INBUF, TYPSTR) from ALIO. ⊗

; FLREAD, SCALIN, VECTIN, TRNSIN

;Routine to read a floating number into location pointed to by R0.
FLREAD:	MOV R0,-(SP)	;Save arg.
	MOV CURIN,R0	;R0 ← current line pointer
FLRD2:	JSR PC,RELSCN	;AC0 ← number typed in
	TST R1		;Got anything?
	BEQ FLRD1	;Yes.
	MOV #INBUF,R0	;No.  Prepare to read a new line.
	JSR PC,INSTR	;
	MOV #INBUF,R0	;
	BR FLRD2	;
FLRD1:	MOV R0,CURIN	;New current line pointer
	STF AC0,@(SP)+	;Put number in desired place.
	RTS PC		;Done

;Routine to get a scalar argument into arg1 or arg2, whichever R0 points to
SCALIN:	OUTSTR SCLMES	;Say we want a scalar
	MOV R0,-(R3)	;Stack the argument
	CLRB @CURIN	;Force a move to new line.
	JSR PC,FLREAD	;Read it.
	RTS PC		;Done
SCLMES:	ASCIE </SCALAR, PLEASE: />
	
;Routine to get a vector argument into arg1 or arg2, whichever R0 points to
VECTIN:	MOV R2,-(SP)	;Save R2
	OUTSTR VCTMES	;Say we want a vector
	MOV R0,-(R3)	;Stack the destination
	MOV R0,-(SP)	;and save a copy on the other stack, too.
	CLRB @CURIN	;Force a move to new line.
	MOV #4,R2	;Need to read 4 scalars
VCTIN1:	JSR PC,FLREAD	;Get one
	MOV (SP),R0	;Retrieve location
	ADD #4,R0	;Update location
	MOV R0,(SP)	;Save it again
	SOB R2,VCTIN1	;Go back and pick up other fields
	TST (SP)+	;Clean off stack
	MOV (SP)+,R2	;Restore R2.
	RTS PC		;Done
VCTMES:	ASCIE </I NEED A VECTOR.  GIVE ME 4 SCALARS, PLEASE:
/>

;Routine to get a trans argument into arg1 or arg2, whichever R0 points to
TRNSIN:	MOV R2,-(SP)	;Save R2
	OUTSTR TRNMES	;Say we want a vector
	CLRB @CURIN	;Force a move to new line.
	MOV R0,-(R3)	;Stack the destination
	MOV R0,-(SP)	;and save a copy on the other stack, too.
	MOV #16.,R2	;Need to read 16 scalars
TRNSN1:	JSR PC,FLREAD	;Get one
	ADD #4,(SP)	;Update location
	MOV (SP),R0	;  and retrieve it.
	SOB R2,TRNSN1	;Go back and pick up other fields
	TST (SP)+	;Clean off stack
	MOV (SP)+,R2	;Restore R2.
	RTS PC		;Done
TRNMES:	ASCIE </I NEED A TRANS.  16 SCALARS, BY  πC O L U M N S:
/>

; SCLOUT, VECOUT, TRNOUT
;Routine to print the scalar argument pointed to by R0
SCLOUT:	LDF (R0),AC0	;Pick up number.
	MOV #OUTBUF,R0	;
	JSR PC,CVG	;Convert it to string
	MOV #OUTBUF,R0	;
	JSR PC,TYPSTR	;Print it.
	RTS PC		;Done

;Routine to print the vector argument pointed to by R0
VECOUT:	MOV R2,-(SP)	;Save R2
	MOV R3,-(SP)	;Save R3
	MOV R0,R2	;R2 ← LOC[next field]
	MOV #4,R3	;Need to print 4 fields
VCOUT1:	LDF (R2)+,AC0	;Pick up a field
	MOV #OUTBUF,R0	;
	JSR PC,CVG	;Convert it to string
	MOV #OUTBUF,R0	;
	JSR PC,TYPSTR	;Print it.
	SOB R3,VCOUT1	;Do all this 4 times
	MOV (SP)+,R3	;Restore R3
	MOV (SP)+,R2	;Restore R2
	RTS PC		;Done

;Routine to print the trans argument pointed to by R0
TRNOUT:	MOV R2,-(SP)	;Save R2
	MOV R3,-(SP)	;Save R3
	MOV R4,-(SP)	;Save R4
	MOV R0,R2	;R2 ← LOC[next field]
	MOV #4,R4	;Need to print 4 cols
TNOUT2:	MOV #4,R3	;Need to print 4 rows
TNOUT1:	LDF (R2)+,AC0	;Pick up a field
	MOV #OUTBUF,R0	;
	JSR PC,CVG	;Convert it to string
	MOV #OUTBUF,R0	;
	JSR PC,TYPSTR	;Print it.
	SOB R3,TNOUT1	;Do all this 4 times
	CRLF		;
	SOB R4,TNOUT2	;Do this for all 4 cols.
	MOV (SP)+,R4	;Restore R4
	MOV (SP)+,R3	;Restore R3
	MOV (SP)+,R2	;Restore R2
	RTS PC		;Done